package com.skzh.web.controller.drawtask;

import com.skzh.common.core.controller.BaseController;
import com.skzh.common.core.domain.AjaxResult;
import com.skzh.common.core.page.TableDataInfo;
import com.skzh.drawtask.domain.DeleteIdsRequest;
import com.skzh.drawtask.domain.TaskPoint;
import com.skzh.drawtask.service.ILineService;
import com.skzh.drawtask.service.IPointService;
import com.skzh.drawtask.service.ISurfaceService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author zr
 * @Description 点任务控制器
 * @Date 2025/3/31 13:31
 */
@RestController
@RequestMapping("/pointTask/pointInfo")
public class Point extends BaseController {

    @Autowired
    private IPointService pointService;

    @Autowired
    private ILineService lineService;

    @Autowired
    private ISurfaceService surfaceService;

    /**
     * 新增点任务
     */
    @ApiOperation(value = "新增点任务")
    @PostMapping
    public AjaxResult add(@RequestBody TaskPoint taskPoint) {
        return toAjax(pointService.insertTaskPoint(taskPoint));
    }

    /**
     * 根据ID删除点任务
     */
    @ApiOperation(value = "根据ID删除点任务")
    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable Long id) {
        return toAjax(pointService.deleteTaskPointById(id));
    }

    /**
     * 根据ID批量删除点任务
     *
     **/
    @ApiOperation(value = "根据ID批量删除点任务")
    @DeleteMapping("/deleteByIds")
    public AjaxResult deleteByIds(@RequestBody DeleteIdsRequest request) {
        List<Long> pointIds = request.getPointIds();
        List<Long> lineIds = request.getLineIds();
        List<Long> surfaceIds = request.getSurfaceIds();
        pointService.deleteTaskPointByIds(pointIds);
        lineService.deleteTaskLineByIds(lineIds);
        surfaceService.deleteTaskSurfaceByIds(surfaceIds);
        return toAjax(1);
    }

    /**
     * 查询点任务
     */
    @ApiOperation(value = "查询点任务")
    @GetMapping("/list")
    public TableDataInfo list(TaskPoint taskPoint) {
            List<TaskPoint> list = pointService.selectTaskPointList(taskPoint);
            return getDataTable(list);
    }

}
